﻿<%@ WebHandler Language="C#" Class="ScoreHandler" %>

using System;
using System.Web;
using DB;
using System.Web.Script.Serialization;

public class ScoreHandler : IHttpHandler
{

    public void ProcessRequest(HttpContext context)
    {
        context.Response.ContentType = "text/plain";
        //context.Request.Params["stdid"];
        string action = context.Request["action"];

        string data_back = "";
        DataAccess da = new DataAccess();
        IScoreSearch scoreSearch = new ScoreSearch();
        IScoreEdit scoreEdit = new ScoreEdit();
        switch (action)
        {
            case "getScoreByCondit":
                string stdid = context.Request["stdid"];
                string exzamid = context.Request["exzamid"];
                string courseid = context.Request["courseid"];
                data_back = scoreSearch.getScoreByCondit(stdid, courseid, exzamid);
                break;
            case "getScoreByCourseStd":
                courseid = context.Request["courseid"];
                 stdid = context.Request["stdid"];
                data_back = scoreSearch.getScoreByCourseStd(courseid, stdid);
                break;
            case "getScoreByTerm":
                stdid = context.Request["stdid"];
                string term = context.Request["term"];
                data_back = scoreSearch.getScoreByTerm(stdid, term);
                break;
            case "getScoreByHistory":
                stdid = context.Request["stdid"];
                data_back = scoreSearch.getScoreByHistory(stdid);
                break;
            case "single_singleSearch":
                stdid = context.Request["stdid"];
                data_back = scoreSearch.singleSearch(stdid);
                break;
            case "getScoreListByExzam":
                exzamid = context.Request["exzamid"];
                data_back = scoreSearch.getScoreListByExzam(exzamid);
                break;
            case "addScoreRow":
                exzamid = context.Request["exzamid"];
                string score = context.Request["score"];
                stdid = context.Request["stdid"];
                scoreEdit.singleAdd(stdid, exzamid, score);
                break;
            case "getScoreByCourse":
                courseid = context.Request["courseid"];
                data_back = scoreSearch.getSocreByCourse(courseid);
                break;
        }
        context.Response.Write(data_back);
    }

    public bool IsReusable
    {
        get
        {
            return false;
        }
    }

}
